<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>新增管理员</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link id="bootstrap-style" href="<c:url value="/css/bootstrap.min.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/bootstrap-responsive.min.css"/>" rel="stylesheet">
	<link id="base-style" href="<c:url value="/css/style.css"/>" rel="stylesheet">
	<link id="base-style-responsive" href="<c:url value="/css/style-responsive.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/index.css"/>" rel="stylesheet">
	<link rel="shortcut icon" href="<c:url value="/img/favicon.ico"/>">
	<link href="<c:url value="/css/page.css"/>" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/jquery.datetimepicker.css"/>"/>
	<link href="<c:url value="/css/but.css"/>" rel="stylesheet">
	<link rel="stylesheet" href="<c:url value="/css/ztree/demo.css"/>" type="text/css">
	<link rel="stylesheet" href="<c:url value="/css/ztree/zTreeStyle/zTreeStyle.css"/>" type="text/css">
	<script type="text/javascript" src="<c:url value="/js/ztree/jquery-1.4.4.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/ztree/jquery.ztree.core.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/ztree/jquery.ztree.excheck.js"/>"></script>
<!-- 	<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script> -->
	<script src="<c:url value="/js/jquery-migrate-1.0.0.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/layer/layer.js"/>"></script>
	<script src="<c:url value="/js/laydate/laydate.js"/>"></script>
	<script src="<c:url value="/js/build/jquery.datetimepicker.full.js"/>"></script>
</head>
 <script type="text/javascript">
 
 
 
 function closebutton() {
	var index = parent.layer.getFrameIndex(window.name);  
 	parent.layer.close(index);  
 }
 


function submitForm(){
	var loginname=$("#login").val();
	var password=$("#loginpassword").val();
	var name=$("#name").val();
	if(loginname==null){
		alert("账号不能为空");
		return;
	}
	if(password==null){
		alert("密码不能为空");
		return;
	}
	if(name==null){
		alert("名称不能为空");
		return;
	}
	document.forms["frm"].submit();
}






var setting = {
		check: {
			enable: true
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onCheck: onCheck
		}
	};

	var zNodes =[${code}];

	var code;

	function setCheck() {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
		py = $("#py").attr("checked")? "p":"",
		sy = $("#sy").attr("checked")? "s":"",
		pn = $("#pn").attr("checked")? "p":"",
		sn = $("#sn").attr("checked")? "s":"",
		type = { "Y":py + sy, "N":pn + sn};
		zTree.setting.check.chkboxType = type;
		showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
	}
	function showCode(str) {
		if (!code) code = $("#code");
		code.empty();
		code.append("<li>"+str+"</li>");
	}

	$(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		setCheck();
		$("#py").bind("change", setCheck);
		$("#sy").bind("change", setCheck);
		$("#pn").bind("change", setCheck);
		$("#sn").bind("change", setCheck);
	});
	
	function onCheck(e, treeId, treeNode) {
		var zTree = jQuery.fn.zTree.getZTreeObj("treeDemo"),
		nodes = zTree.getCheckedNodes(true),
		v = ",";
		for (var i=0, l=nodes.length; i<l; i++) {
			if(!nodes[i].getCheckStatus().half){
				if(v.indexOf(","+nodes[i].pId+",")==-1){
					v += nodes[i].id + ",";
				}
			}
		}

		v=v.substr(1);
		if (v.length > 0 ) v = v.substring(0, v.length-1);
		
		jQuery("#powerIds").val(v);
	}
		
	jQuery(document).ready(function(){
		jQuery.fn.zTree.init(jQuery("#treeDemo"), setting, zNodes);
	});
	
 </script>
<body>
 <input type="hidden" id="py" class="checkbox first" checked />
 <input type="hidden" id="sy" class="checkbox first" checked />
 <input type="hidden" id="pn" class="checkbox first" checked />
 <input type="hidden" id="sn" class="checkbox first" checked />
	<form name="frm" id="frm" method="post" action="<%=basePath%>permissions/insert"  style="width: 700px;">
	 <input name="powerIds" id="powerIds" type="hidden" value="">
			<div id="content" class="span10" style="width: 100%;">
				<div class="row-fluid content-table">
					<table id="tab" class="table table-striped table-bordered bootstrap-datatable">
					  <tbody>
						<tr>
							<td style="text-align:right;vertical-align:middle;">账号：</td>
							<td  style="text-align:left;vertical-align:middle;">
								<input style="margin-bottom:0px;" maxlength="25" type="text" id="login" name="login" value="">
							</td>
							<td style="text-align:right;vertical-align:middle;">密码：</td>
							<td  style="text-align:left;vertical-align:middle;">
								<input style="margin-bottom:0px;" maxlength="25" type="password" id="loginpassword" name="loginpassword" value="">
							</td>
						</tr>
						<tr>
							<td style="text-align:right;vertical-align:middle;">名称：</td>
							<td  style="text-align:left;vertical-align:middle;">
								<input style="margin-bottom:0px;" maxlength="25" type="text" id="name" name="name" value="">
							</td>
							<td style="text-align:right;vertical-align:middle;">邮寄：</td>
							<td  style="text-align:left;vertical-align:middle;">
								<input style="margin-bottom:0px;" maxlength="50" type="text" id="email" name="email" value="">
							</td>
						</tr>
						<tr>
							<td style="text-align:right;vertical-align:middle;">手机号：</td>
							<td  style="text-align:left;vertical-align:middle;" >
								<input style="margin-bottom:0px;" maxlength="11" type="text" id="mobile" name="mobile" value="">
							</td>
							<td style="text-align:right;vertical-align:middle;">状态：</td>
							<td  style="text-align:left;vertical-align:middle;">
								<select  class="pay paytype" name="status" id="status" style="width: 150px;margin-bottom:0px;">
										<option value="0" >启用</option>
										<option value="1" >暂停</option>
									</select>
							</td>
						</tr>
						<tr>
							<td style="text-align:right;vertical-align:middle;">权限设置：</td>
							<td  style="text-align:left;vertical-align:middle;" colspan="3" >
								<div class="content_wrap">
									<div class="zTreeDemoBackground left">
										<ul id="treeDemo" class="ztree"></ul>
									</div>
								</div>
							</td>
						</tr>
						<tr class="content-search" style="text-align: center;vertical-align:middle;">
							<td colspan="5" style="width:100%;">
								<div>
									<button style="background-color:#f55353;" type="button" onclick="closebutton();" id="output1">关闭</button>
									<button class="but" type="button" id="output" onclick="submitForm();">确定</button>
								</div>
							</td>
						</tr>
					  </tbody>
				  </table>            
				</div>	
			</div>
	</form>
</body>
 <script type="text/javascript">
 $(function(){ 
	 var msg="${msg}";
	 if(msg!=null&&msg!=""){
		 alert(msg);
		 window.parent.location.reload(); //刷新父页面
		 var index = parent.layer.getFrameIndex(window.name);  
		 parent.layer.close(index);  
	 }
 }); 

 </script>
</html>
